<template>
	<div>
		<!-- <mealInfoDetail :mealInfo="mealInfos"></mealInfoDetail> -->
		<el-table :data="longOrderList" height="700" border style="width: 100%;">
			<el-table-column prop="longid" label="订单id" width="150">
			</el-table-column>
			<el-table-column prop="longstate" label="订单状态" width="150">
			</el-table-column>
			<el-table-column prop="longcreatetime" label="订单时间" width="150">
			</el-table-column>
			<el-table-column prop="longprice" label="套餐价格">
			</el-table-column>
			<el-table-column label="操作" width="250" fixed="right">
				<template slot-scope="scope">
					<el-button @click="handleClick(scope.row)" type="text" size="small" icon="el-icon-document">详情</el-button>
					<!-- <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button> -->
				</template>
			</el-table-column>
		</el-table>
		<longOrderInfoDetail :longOrder="longOrder" :staffList="staffList"></longOrderInfoDetail>
	</div>
</template>
<script>
	// import mealInfoDetail from '@/components/major_meal_info/Major_meal_info_detail.vue'
	 import longOrderInfoDetail from '@/components/long_order_info/long_order_info_detail.vue'
	import {
		request
	} from "network/request.js"

	export default {
		props: {
			longOrderList: {}
			// [{
			// 	"longcreatetime": "2019-10-13T13:05:22.397Z",
			// 	"longdetail": "string",
			// 	"longedtime": "2019-10-13T13:05:22.398Z",
			// 	"longid": 0,
			// 	"longprice": 0,
			// 	"longremark": "string",
			// 	"longremark2": "string",
			// 	"longretime": "2019-10-13T13:05:22.398Z",
			// 	"longstate": "string",
			// 	"mealid": 0,
			// 	"u2id": 0,
			// 	"uid": 0
			// }],
		},
		components: {
			longOrderInfoDetail
		},
		data() {
			return {
				longOrder: {
					"longcreatetime": "2019-10-13T13:05:22.397Z",
					"longdetail": "string",
					"longedtime": "2019-10-13T13:05:22.398Z",
					"longid": 0,
					"longprice": 0,
					"longremark": "string",
					"longremark2": "string",
					"longretime": "2019-10-13T13:05:22.398Z",
					"longstate": "string",
					"mealid": 0,
					"u2id": 0,
					"uid": 0
				},
				staffList: []
			}
		},
		methods: {
			handleClick(row) {
				request({
					url: '/Order/longOrederId',
					method: 'get',
					params: {
						// id:this.$store.state.mealid
						id: row.longid
					}
				}).then(res => {
					this.longOrder = res.data
					return request({
						url: '/User2/userInfo2u2id',
						method: 'get',
						params: {
							// id:this.$store.state.mealid
							u2id: res.data.u2id
						}
					})
				}).then(res => {
					this.longOrder.u2id = res.data
					return request({
						url: '/Meal/Meal',
						method: 'get',
						params: {
							// id:this.$store.state.mealid
							id: row.mealid
						}
					})
				}).then(res => {
					this.longOrder.mealid = res.data
					return request({
						url: '/User/UserInfo',
						method: 'get',
						params: {
							// id:this.$store.state.mealid
							uid: row.uid
						}
					})
				}).then(res => {
					this.longOrder.uid = res.data
					// console.log(this.longOrder)
					this.$store.commit("updateLongOrderInfoflag", true)
				})
				if (row.longstate != "未服务") {
					this.staffList=[]
					request({
						url: '/OrderEmp/LonginfoByLonginfoId',
						method: 'get',
						params: {
							// id:this.$store.state.mealid
							longInfoId: row.longid
						}
					}).then(res => {

						return 	request({
						url: '/Emp/empInfo',
						method: 'get',
						params: {
							// id:this.$store.state.mealid
							empid: res.data.empid
						}
					})
					}).then(res=>{
						this.staffList.push(res.data)
					})


				} else {
					request({
						url: '/Emp/empInfos',
						method: 'get'
					}).then(res => {
						this.staffList = []
						res.data.forEach(e => {
							if (e.emptype == 'A' && e.empstate == '2') {
								this.staffList.push(e)
							}
						})
					})
				}



			}

		}
	}
</script>
<style>
	el-table-column {
		height: 50px;
	}

	.el-main {
		line-height: 20px;
	}
</style>
